package org.niu.dp;

import java.util.HashSet;
import java.util.Set;

public class MaxLen {
    public int maxLength (int[] arr) {
        // write code here
        Set<Integer> set = new HashSet<>();
        int ans = 1;
        set.add(arr[0]);
        int max_n = -1;
        for(int i = 1; i < arr.length;i++){
            System.out.println(ans);
            if(set.contains(arr[i])){
                max_n = Math.max(max_n,ans);
                ans = 0;
                set.clear();
            }
            else {ans++;set.add(arr[i]);}

        }
        return max_n;
    }
}
